package com.risk.modules.rm.service.business;

import com.google.gson.JsonObject;
import com.risk.common.Enums.DataEnum;
import com.risk.common.beans.JsonResult;
import com.risk.common.utils.R;
import com.risk.modules.rm.selector.ServiceProvider;
import com.wxapi.WxApiCall.WxApiCall;
import com.wxapi.model.RequestModel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Date;
import java.util.Map;

public abstract class BusinessService implements ServiceProvider<DataEnum> {
    private final static Logger logger = LoggerFactory.getLogger(BusinessService.class);

    private static final String JD_APPKEY = "f4968348c159218060fe80cb3f343aef";

    public R query(String name,String idCard,String phone,String bankCard){
        JsonResult result = new JsonResult();
        return R.ok().put("data",resultHandle(execute(name,idCard,phone,bankCard),new Date()));
    }

    public abstract String execute(String name,String idCard,String phone,String bankCard);

    public abstract String resultHandle(String result,Date handleTime);

    public static String apiSend(String url,Map queryMap){
        RequestModel model = new RequestModel();
        model.setGwUrl(url);
        model.setAppkey(JD_APPKEY);
        model.setQueryParams(queryMap);
        WxApiCall call = new WxApiCall();
        call.setModel(model);
        return call.request();
    }
}
